package com.gupao.edu.study.singleton;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: guqy
 * @Description:
 * @Date 11:28 2018/3/19
 */
public class SpringRegister {
    private SpringRegister(){}
    private static Map ioc = new ConcurrentHashMap();
    public static Object getBean(String beanName) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        if(ioc.containsKey(beanName)){
            return ioc.get(beanName);
        }else{
            Object obj = Class.forName(beanName).newInstance();
            return ioc.put(beanName,obj);
        }
    }
}
